package com.ld.admin.service.oa;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.ld.admin.model.oa.SysUserSeatsModel;
import com.ld.shieldsb.common.core.model.Result;
import com.ld.shieldsb.common.core.reflect.ClassUtil;
import com.ld.shieldsb.common.web.BasicService;
import com.ld.shieldsb.common.web.util.Web;

/**
 * 
 * 待办事项服务类，@Service注解用于自动注入
 * 
 * @ClassName OaTodolistService
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2019年07月18日 10:33:36
 *
 */
@Service
public class SysUserSeatsService extends BasicService {
    public Result save(String params) {
        Result result = new Result();
        String[] paramsArrs = params.split(",");
        List<SysUserSeatsModel> modelList = new ArrayList<>();
        if (paramsArrs != null && paramsArrs.length > 0) {
            for (String pStr : paramsArrs) {
                String[] dataArrs = pStr.split("-");
                if (dataArrs.length >= 5) {
                    SysUserSeatsModel seatModel = new SysUserSeatsModel();
                    Long id = ClassUtil.obj2long(dataArrs[0]);
                    String topv = dataArrs[1];
                    String leftv = dataArrs[2];
                    String height = dataArrs[3];
                    String width = dataArrs[4];
                    seatModel.setId(id);
                    seatModel.setTopv(topv);
                    seatModel.setLeftv(leftv);
                    seatModel.setHeight(height);
                    seatModel.setWidth(width);
                    modelList.add(seatModel);
                }
            }
            result = addOrUpdate(modelList, true);
            if (result.getSuccess()) {
                return Web.Response.success("保存成功！");
            } else {
                return Web.Response.error("保存失败！" + result.getMessage());
            }
        }
        return result;
    }
}
